<!--
 * @Author: huangtianyang 916072572@qq.com
 * @Date: 2023-03-10 10:01:24
 * @LastEditors: huangtianyang
 * @LastEditTime: 2023-08-02 15:16:06
 * @FilePath: \cxl-h5\src\pages\webview\Index.vue
-->
<template>
    <section class="webview">
        <iframe :src="webUrl" frameborder="0" v-if="webUrl"></iframe>
        <section v-else>
            <img src="../../assets/images/wbb.png" alt="" />
        </section>
    </section>
</template>

<script setup lang="ts">
import { getShareData } from '@/apis/report'
import useWeixinSdk from '@/utils/WXSdk'
import { ref, onMounted } from 'vue'
import { useRoute } from 'vue-router'
//路由
const route = useRoute()
//展示url
const webUrl = ref('')
webUrl.value = route.query.url as string
//报告id
const reportId = ref('')
reportId.value = route.query.reportId as string
console.log('reportId', reportId.value)
//判断是否从案例入口进入
const fromCase = ref('')
fromCase.value = (route.query.type as string) ?? ''
onMounted(() => {
    // editPageTitle('车辆维保车况报告')
    useWeixinSdk.ableShare()
    if (!fromCase.value) {
        getShareData(reportId.value).then((res: any) => {
            if (res.data.value === 200) {
                useWeixinSdk.shareReport2({
                    title: res.data.data.plateNo + '的车况报告',
                    desc: `vin：${res.data.data.vin}\r\n生成时间：${res.data.data.generateTime}`,
                    link: window.location.href,
                    imgUrl: res.data.data.brandLogo
                })
            }
        })
    }
})
</script>

<style scoped lang="scss">
.webview {
    width: 100%;
    height: 100vh;
    iframe {
        display: block;
        margin: 0;
        padding: 0;
        width: 100%;
        height: 100%;
    }
    > section {
        width: 100%;
        height: 100%;
        overflow-y: auto;
        img {
            display: block;
            width: 100%;
        }
    }
}
</style>
